<template>
	<view>
		<image src="/static/mybj.png" class="qjimg" mode=""></image>
		<view class="">
			<view class="toptit" :style="'margin-top:'+top+'px;'">
				我的
			</view>
			<view class="grxx">
				<image :src="userdata.headimgurl[0]?userdata.headimgurl[0]:'../../static/tx.png'" mode=""></image>
				<view class="grxx1">
					<view class="grxx1-1">
						{{userdata.userName?userdata.userName:'李某某'}}

						<view class="grxx1-1-1" v-for="(item,index) in userdata.group" :key="index">
							{{item}}
						</view>
					</view>
					<view class="grxx1-2">
						{{userdata.phoneNumber?userdata.phoneNumber:'188***8881'}}
					</view>
				</view>
			</view>
			<view class="caozuyo">
				<view class="caozuyo1" @click="xiugaimima">
					<view class="">
						修改密码
					</view>
					<image src="/static/yzk.png" mode=""></image>
				</view>
				<view class="caozuyo1" @click="huancun">
					<view class="">
						清空缓存
					</view>
					<image src="/static/yzk.png" mode=""></image>
				</view>
				<view class="caozuyo1" @click="denglu">
					<view class="">
						退出登录
					</view>
					<image src="/static/yzk.png" mode=""></image>
				</view>
			</view>
		</view>
		<uni-popup ref="popup" type="center" :animation="false">
			<view class="huancun">
				<view class="hctitle">
					清除缓存
				</view>
				<view class="hccenter" style="margin-top: 20rpx;">
					您确认要清除应用所有缓存吗？
				</view>
				<view class="hccenter">
					清除缓存后可能导致部分数据需要重新
				</view>
				<view class="hccenter">
					通过网络获取，请谨慎清除！
				</view>
				<view class="bottom">
					<view class="bottom1" @click="cancel">
						取消
					</view>
					<view class="bottom2" @click="qingchu">
						清楚
					</view>
				</view>
			</view>
		</uni-popup>
		<uni-popup ref="popup1" type="center" :animation="false">
			<view class="huancun" style="height:218rpx ;">
				<view class="hctitle" style="margin-top: 37rpx;">
					退出登录
				</view>
				<view class="hccenter" style="margin-top: 20rpx;">
					您确认要退出当前账号吗？
				</view>
				<view class="bottom">
					<view class="bottom1" @click="cancel">
						取消
					</view>
					<view class="bottom2" @click="leave">
						退出
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				top: 0,
				userdata: {},
				token: ''
			}
		},
		onLoad() {
			let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
			// this.CustomBar = menuButtonInfo.bottom * 1 + 10
			this.top = menuButtonInfo.top * 1 + 10
			this.token = uni.getStorageSync('token')
			if (this.token) {
				this.$post('wuyecenter/getuser', {}, res => {
					console.log(res.data);
					this.userdata = res.data

				})
			} else {
				console.log('请登录!');
				uni.showToast({
					title: '请登录',
					icon: 'none',
					duration: 3000
				})
			}

		},
		methods: {
			xiugaimima() {
				if (this.token) {
					uni.navigateTo({
						url: '/pages/index/my/ModifyPassword'
					})
				} else {
					uni.showToast({
						title: '请登录!',
						icon: 'none',
						duration: 1500
					})
					setTimeout(res => {
						uni.navigateTo({
							url: '/pages/login/login'
						})
					}, 1500)
				}
			},
			huancun() {
				if (this.token) {
					this.$refs.popup.open('center')
				} else {
					uni.showToast({
						title: '请登录!',
						icon: 'none',
						duration: 1500
					})
					setTimeout(res => {
						uni.navigateTo({
							url: '/pages/login/login'
						})
					}, 1500)
				}
			},
			denglu() {
				if (this.token) {
					this.$refs.popup1.open('center')
				} else {
					uni.showToast({
						title: '请登录!',
						icon: 'none',
						duration: 1500
					})
					setTimeout(res => {
						uni.navigateTo({
							url: '/pages/login/login'
						})
					}, 1500)

				}
			},
			qingchu() {
				uni.clearStorage()
				this.$refs.popup.close()

			},
			cancel() {
				this.$refs.popup.close()
				this.$refs.popup1.close()
			},
			leave() {
				uni.clearStorage()
				this.$refs.popup1.close()
				uni.reLaunch({
					url: '/pages/login/login'
				})
			}
		}
	}
</script>

<style lang="scss">
	.qjimg {
		width: 750rpx;
		height: 717rpx;
		position: absolute;
		top: 0;
		z-index: -1;
	}

	.toptit {
		text-align: center;
		font-size: 36rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #ffffff;
	}

	.grxx {
		display: flex;
		align-items: center;
		margin-top: 70rpx;
		margin-left: 28rpx;

		>image {
			height: 124rpx;
			width: 124rpx;
		}
	}

	.grxx1 {
		margin-left: 30rpx;
	}

	.grxx1-1 {
		display: flex;
		align-items: center;
		font-size: 36rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #FFFFFF;
		line-height: 20rpx;

		.grxx1-1-1 {
			margin-left: 10rpx;
			background-color: #34d6c0;
			border-radius: 10rpx;
			width: 88rpx;
			height: 32rpx;
			font-size: 18rpx;
			text-align: center;
			font-family: Source Han Sans CN;
			font-weight: 500;
			color: #000000;
			line-height: 32rpx;
		}
	}

	.grxx1-2 {
		margin-top: 20rpx;
		font-size: 24rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #FFFFFF;
		line-height: 20rpx;
	}

	.caozuyo {
		width: 620rpx;
		margin: 120rpx auto;
	}

	.caozuyo1 {
		margin: 60rpx 0;
		display: flex;
		justify-content: space-between;
		align-items: center;

		>view {
			font-size: 30rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #333333;
			line-height: 24rpx;
		}

		>image {
			width: 9rpx;
			height: 17rpx;
		}
	}

	.huancun {
		width: 439rpx;
		height: 356rpx;
		background-color: #FFFFFF;
		overflow: hidden;
	}

	.hctitle {
		margin-top: 76rpx;
		font-size: 20rpx;
		font-family: Alibaba PuHuiTi;
		font-weight: 500;
		color: #000000;
		text-align: center;
	}

	.hccenter {
		font-size: 20rpx;
		font-family: Alibaba PuHuiTi;
		font-weight: 400;
		color: #999999;
		line-height: 30rpx;
		text-align: center;
	}

	.bottom {
		width: 439rpx;
		position: absolute;
		bottom: 0;
		display: flex;
		height: 80rpx;
		border-top: #dddddd solid 2rpx;
	}

	.bottom1 {
		width: 50%;
		border-right: #dddddd solid 2rpx;
		text-align: center;
		font-size: 20rpx;
		font-family: Alibaba PuHuiTi;
		font-weight: 400;
		color: #000000;
		line-height: 80rpx;
	}

	.bottom2 {
		width: 50%;
		text-align: center;
		font-size: 20rpx;
		font-family: Adobe Heiti Std;
		font-weight: normal;
		color: #2D75FC;
		line-height: 80rpx;

	}
</style>
